<template>
  <div>
    <!-- 面包屑导航区 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>驾校信息</el-breadcrumb-item>
      <el-breadcrumb-item>报名申请</el-breadcrumb-item>
    </el-breadcrumb>

    <el-card>
      <!-- 考试列表区域 -->
      <el-table :data="applyList" border stripe>
        <el-table-column type="index"></el-table-column>
        <el-table-column label="id" prop="id" v-if="false"></el-table-column>
        <el-table-column label="套餐名称" prop="name" width="164px"></el-table-column>
        <el-table-column label="科目一训练课时" prop="subjectOneTime" width="120px">
          <template slot-scope="scope">
            {{ scope.row.subjectOneTime }} 小时
          </template>
        </el-table-column>
        <el-table-column label="科目二训练课时" prop="subjectTwoTime" width="120px">
          <template slot-scope="scope">
            {{ scope.row.subjectTwoTime }} 小时
          </template>
        </el-table-column>
        <el-table-column label="科目三训练课时" prop="subjectThreeTime" width="120px">
          <template slot-scope="scope">
            {{ scope.row.subjectThreeTime }} 小时
          </template>
        </el-table-column>
        <el-table-column label="科目四训练课时" prop="subjectFourTime" width="120px">
          <template slot-scope="scope">
            {{ scope.row.subjectFourTime }} 小时
          </template>
        </el-table-column>
        <el-table-column label="科目一考试次数" prop="subjectOneExam" width="120px">
          <template slot-scope="scope">
            {{ scope.row.subjectOneExam }} 次
          </template>
        </el-table-column>
        <el-table-column label="科目二考试次数" prop="subjectTwoExam" width="120px">
          <template slot-scope="scope">
            {{ scope.row.subjectTwoExam }} 次
          </template>
        </el-table-column>
        <el-table-column label="科目三考试次数" prop="subjectThreeExam" width="120px">
          <template slot-scope="scope">
            {{ scope.row.subjectThreeExam }} 次
          </template>
        </el-table-column>
        <el-table-column label="科目四考试次数" prop="subjectFourExam" width="120px">
          <template slot-scope="scope">
            {{ scope.row.subjectFourExam }} 次
          </template>
        </el-table-column>
        <el-table-column label="价格" prop="price" width="100px"></el-table-column>


        <el-table-column label="操作" width="130px">
          <template slot-scope="scope">
            <!-- 报名按钮 -->
            <el-button type="primary" icon="el-icon-s-claim" size="mini"
                       @click="apply(scope.row.id)">报名
            </el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "Apply",
  data() {
    return {
      applyList: []
    }
  },
  created() {
    this.getApplyList()
  },
  methods: {
    getApplyList() {
      this.$http.get('/driver/applicationPackage/getApplyList').then(res => {
        if (res.data.code === 200) {
          this.applyList = res.data.data
        } else {
          this.$message.error(res.data.message)
        }
      }).catch(err => {
        console.log(err)
        this.$message.error(err.message)
      })
    },
    apply(data) {
      this.$http.get('/driver/studentApply/apply', {
        params: {
          id: data
        }
      }).then(res => {
        if (res.data.code === 200) {
          this.$message.success(res.data.message)
        } else {
          this.$message.error(res.data.message)
        }
      }).catch(err => {
        console.log(err)
        this.$message.error(err.message)
      })
    }
  }
}
</script>

<style scoped>

</style>
